﻿using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using WMS_MAV;

namespace WMS_MAV.Controllers
{
    public class UserController : Controller
    {
        public IActionResult Index()
        {
            return View();
        }
        public IActionResult Dogin()
        {
            return View();
        }
        public IActionResult UserAdd()
        {
            return View();
        }
        public IActionResult Role()
        {
            return View();
        }
        [HttpPost]
        public async Task<ActionResult> UserAddDo(string model,string token)
        {
            HttpClientWrapper httpClientWrapper = new HttpClientWrapper(token);
            string url = "http://1.117.93.87:8000/rbacxie/api/User/userCreate";
            var datas = JsonConvert.SerializeObject(model);
            var response = await httpClientWrapper.PostAsync(url, model);
            return Json(response);
        }
        [HttpPost]
        public async Task<ActionResult> RoleDo(string model, string token)
        {
            HttpClientWrapper httpClientWrapper = new HttpClientWrapper(token);
            string url = "http://1.117.93.87:8000/rbacxie/api/Role/roleCreate";
            var datas = JsonConvert.SerializeObject(model);
            var response = await httpClientWrapper.PostAsync(url, model);
            return Json(response);
        }
        [HttpPost]
        public async Task<ActionResult> DoginDo(string model)
        {
            string token = "";
            HttpClientWrapper httpClientWrapper = new HttpClientWrapper(token);
            string url = "http://1.117.93.87:8000/rbacdu/api/Login/Login";
            var response = await httpClientWrapper.PostAsync(url, model);
            return Json(response);
        }
        public IActionResult UseRoleAdd()
        {
            return View();
        }
        [HttpGet]
        public async Task<ActionResult> UserBang(string token)
        {
            HttpClientWrapper httpClientWrapper = new HttpClientWrapper(token);
            string url = "http://1.117.93.87:8000/rbacdu/api/User/UserSelectShow";
            var response = await httpClientWrapper.GetAsync(url);
            return Json(response);
        }
        [HttpGet]
        public async Task<ActionResult> RoleBang(string token)
        {
            HttpClientWrapper httpClientWrapper = new HttpClientWrapper(token);
            string url = "http://1.117.93.87:8000/rbacdu/api/Role/RoleSelectShow";
            var response = await httpClientWrapper.GetAsync(url);
            return Json(response);
        }
        [HttpPost]
        public async Task<ActionResult> UseRoleAddDo(string model,string token)
        {
            HttpClientWrapper httpClientWrapper = new HttpClientWrapper(token);
            string url = "http://1.117.93.87:8000/rbacxie/api/Role/UserRoleCreate";
            var response = await httpClientWrapper.PostAsync(url,model);
            return Json(response);
        }
        public IActionResult MenuAdd()
        {
            return View();
        }
        [HttpGet]
        public async Task<ActionResult> MenuBang(string model, string token)
        {
            HttpClientWrapper httpClientWrapper = new HttpClientWrapper(token);
            string url = "http://1.117.93.87:8000/rbacdu/api/Menu/MenuSelectShow";
            var response = await httpClientWrapper.GetAsync(url);
            return Json(response);
        }
        [HttpPost]
        public async Task<ActionResult> MenuAddDo(string model, string token)
        {
            HttpClientWrapper httpClientWrapper = new HttpClientWrapper(token);
            string url = "http://1.117.93.87:8000/rbacxie/api/Menu/menuCreate";
            var response = await httpClientWrapper.PostAsync(url, model);
            return Json(response);
        }
        public IActionResult MenuShow()
        {
            return View();
        }
        [HttpGet]
        public async Task<ActionResult> MenuTree(string model, string token)
        {
            HttpClientWrapper httpClientWrapper = new HttpClientWrapper(token);
            string url = "http://1.117.93.87:8000/rbacdu/api/Menu/MenuTreeShow";
            var response = await httpClientWrapper.GetAsync(url);
            return Json(response);
        }
        [HttpPost]
        public async Task<ActionResult> MenuRoleDo(string model, string token)
        {
            HttpClientWrapper httpClientWrapper = new HttpClientWrapper(token);
            string url = "http://1.117.93.87:8000/rbacxie/api/Menu/RoleMenu";
            var response = await httpClientWrapper.PostAsync(url, model);
            return Json(response);
        }
        [HttpPost]
        public async Task<ActionResult> MenuRoleIsdel(string model, string token)
        {
            HttpClientWrapper httpClientWrapper = new HttpClientWrapper(token);
            string url = "http://1.117.93.87:8000/rbacxie/api/Menu/menuDelete";
            var response = await httpClientWrapper.PostAsync(url, model);
            return Json(response);
        }
    }
}
